<!DOCTYPE html>
<html lang="en-US">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>知识总结（六）JavaScript基础 | lty的博客</title>
    <meta name="generator" content="VuePress 1.8.2">
    <link rel="icon" href="/blog/favicon.ico">
    <meta name="description" content="山重水复疑无路，柳暗花明又一村">
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no">
    
    <link rel="preload" href="/blog/assets/css/0.styles.ca934e57.css" as="style"><link rel="preload" href="/blog/assets/js/app.2c497286.js" as="script"><link rel="preload" href="/blog/assets/js/3.1e41fb2d.js" as="script"><link rel="preload" href="/blog/assets/js/1.a1bf8e1e.js" as="script"><link rel="preload" href="/blog/assets/js/36.3350110b.js" as="script"><link rel="prefetch" href="/blog/assets/js/10.595db545.js"><link rel="prefetch" href="/blog/assets/js/11.a57c5d33.js"><link rel="prefetch" href="/blog/assets/js/12.bbd60eab.js"><link rel="prefetch" href="/blog/assets/js/13.0a322639.js"><link rel="prefetch" href="/blog/assets/js/14.45182424.js"><link rel="prefetch" href="/blog/assets/js/15.8bfecd82.js"><link rel="prefetch" href="/blog/assets/js/16.f295f32f.js"><link rel="prefetch" href="/blog/assets/js/17.de5dabe7.js"><link rel="prefetch" href="/blog/assets/js/18.dbcf4366.js"><link rel="prefetch" href="/blog/assets/js/19.dc4ed650.js"><link rel="prefetch" href="/blog/assets/js/20.9000ffe3.js"><link rel="prefetch" href="/blog/assets/js/21.50c08d3d.js"><link rel="prefetch" href="/blog/assets/js/22.849f004a.js"><link rel="prefetch" href="/blog/assets/js/23.4c25a240.js"><link rel="prefetch" href="/blog/assets/js/24.a2930e6d.js"><link rel="prefetch" href="/blog/assets/js/25.20efd6e6.js"><link rel="prefetch" href="/blog/assets/js/26.1881faa9.js"><link rel="prefetch" href="/blog/assets/js/27.18bc2dfe.js"><link rel="prefetch" href="/blog/assets/js/28.903117fb.js"><link rel="prefetch" href="/blog/assets/js/29.e1d01502.js"><link rel="prefetch" href="/blog/assets/js/30.27049c11.js"><link rel="prefetch" href="/blog/assets/js/31.455cb7a6.js"><link rel="prefetch" href="/blog/assets/js/32.72aa7ec8.js"><link rel="prefetch" href="/blog/assets/js/33.6362e43e.js"><link rel="prefetch" href="/blog/assets/js/34.30160844.js"><link rel="prefetch" href="/blog/assets/js/35.991fefa1.js"><link rel="prefetch" href="/blog/assets/js/37.38b67684.js"><link rel="prefetch" href="/blog/assets/js/38.33876f62.js"><link rel="prefetch" href="/blog/assets/js/4.870f2524.js"><link rel="prefetch" href="/blog/assets/js/5.516ed845.js"><link rel="prefetch" href="/blog/assets/js/6.710883e3.js"><link rel="prefetch" href="/blog/assets/js/7.3579268a.js"><link rel="prefetch" href="/blog/assets/js/8.1e580575.js"><link rel="prefetch" href="/blog/assets/js/9.08e245bf.js">
    <link rel="stylesheet" href="/blog/assets/css/0.styles.ca934e57.css">
  </head>
  <body>
    <div id="app" data-server-rendered="true"><div class="theme-container no-sidebar" data-v-1aefc0b4><div data-v-1aefc0b4><div id="loader-wrapper" class="loading-wrapper" data-v-d48f4d20 data-v-1aefc0b4 data-v-1aefc0b4><div class="loader-main" data-v-d48f4d20><div data-v-d48f4d20></div><div data-v-d48f4d20></div><div data-v-d48f4d20></div><div data-v-d48f4d20></div></div> <!----> <!----></div> <div class="password-shadow password-wrapper-out" style="display:none;" data-v-25ba6db2 data-v-1aefc0b4 data-v-1aefc0b4><h3 class="title" data-v-25ba6db2 data-v-25ba6db2>lty的博客</h3> <p class="description" data-v-25ba6db2 data-v-25ba6db2>山重水复疑无路，柳暗花明又一村</p> <label id="box" class="inputBox" data-v-25ba6db2 data-v-25ba6db2><input type="password" value="" data-v-25ba6db2> <span data-v-25ba6db2>Konck! Knock!</span> <button data-v-25ba6db2>OK</button></label> <div class="footer" data-v-25ba6db2 data-v-25ba6db2><span data-v-25ba6db2><i class="iconfont reco-theme" data-v-25ba6db2></i> <a target="blank" href="https://vuepress-theme-reco.recoluan.com" data-v-25ba6db2>vuePress-theme-reco</a></span> <span data-v-25ba6db2><i class="iconfont reco-copyright" data-v-25ba6db2></i> <a data-v-25ba6db2><span data-v-25ba6db2>lty</span>
            
          <!---->
          2022
        </a></span></div></div> <div class="hide" data-v-1aefc0b4><header class="navbar" data-v-1aefc0b4><div class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/blog/" class="home-link router-link-active"><img src="/blog/logo.png" alt="lty的博客" class="logo"> <span class="site-name">lty的博客</span></a> <div class="links"><div class="color-picker"><a class="color-button"><i class="iconfont reco-color"></i></a> <div class="color-picker-menu" style="display:none;"><div class="mode-options"><h4 class="title">Choose mode</h4> <ul class="color-mode-options"><li class="dark">dark</li><li class="auto active">auto</li><li class="light">light</li></ul></div></div></div> <div class="search-box"><i class="iconfont reco-search"></i> <input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="/blog/" class="nav-link"><i class="iconfont reco-home"></i>
  主页
</a></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title"><i class="iconfont reco-category"></i>
      分类
    </span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/blog/categories/JavaScript/" class="nav-link"><i class="undefined"></i>
  JavaScript
</a></li><li class="dropdown-item"><!----> <a href="/blog/categories/投资/" class="nav-link"><i class="undefined"></i>
  投资
</a></li><li class="dropdown-item"><!----> <a href="/blog/categories/计算机网络/" class="nav-link"><i class="undefined"></i>
  计算机网络
</a></li><li class="dropdown-item"><!----> <a href="/blog/categories/前端相关/" class="nav-link"><i class="undefined"></i>
  前端相关
</a></li><li class="dropdown-item"><!----> <a href="/blog/categories/知识总结/" class="nav-link"><i class="undefined"></i>
  知识总结
</a></li></ul></div></div><div class="nav-item"><a href="/blog/tag/" class="nav-link"><i class="iconfont reco-tag"></i>
  标签
</a></div><div class="nav-item"><a href="/blog/timeline/" class="nav-link"><i class="iconfont reco-date"></i>
  时间线
</a></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title"><i class="iconfont reco-message"></i>
      关于
    </span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="https://gitee.com/ekzodia_lty" target="_blank" rel="noopener noreferrer" class="nav-link external"><i class="iconfont reco-mayun"></i>
  Gitee
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li></ul></div></div> <!----></nav></div></header> <div class="sidebar-mask" data-v-1aefc0b4></div> <aside class="sidebar" data-v-1aefc0b4><div class="personal-info-wrapper" data-v-39576ba9 data-v-1aefc0b4><img src="/blog/avatar.jpg" alt="author-avatar" class="personal-img" data-v-39576ba9> <h3 class="name" data-v-39576ba9>
    lty
  </h3> <div class="num" data-v-39576ba9><div data-v-39576ba9><h3 data-v-39576ba9>27</h3> <h6 data-v-39576ba9>Articles</h6></div> <div data-v-39576ba9><h3 data-v-39576ba9>18</h3> <h6 data-v-39576ba9>Tags</h6></div></div> <ul class="social-links" data-v-39576ba9></ul> <hr data-v-39576ba9></div> <nav class="nav-links"><div class="nav-item"><a href="/blog/" class="nav-link"><i class="iconfont reco-home"></i>
  主页
</a></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title"><i class="iconfont reco-category"></i>
      分类
    </span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/blog/categories/JavaScript/" class="nav-link"><i class="undefined"></i>
  JavaScript
</a></li><li class="dropdown-item"><!----> <a href="/blog/categories/投资/" class="nav-link"><i class="undefined"></i>
  投资
</a></li><li class="dropdown-item"><!----> <a href="/blog/categories/计算机网络/" class="nav-link"><i class="undefined"></i>
  计算机网络
</a></li><li class="dropdown-item"><!----> <a href="/blog/categories/前端相关/" class="nav-link"><i class="undefined"></i>
  前端相关
</a></li><li class="dropdown-item"><!----> <a href="/blog/categories/知识总结/" class="nav-link"><i class="undefined"></i>
  知识总结
</a></li></ul></div></div><div class="nav-item"><a href="/blog/tag/" class="nav-link"><i class="iconfont reco-tag"></i>
  标签
</a></div><div class="nav-item"><a href="/blog/timeline/" class="nav-link"><i class="iconfont reco-date"></i>
  时间线
</a></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title"><i class="iconfont reco-message"></i>
      关于
    </span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="https://gitee.com/ekzodia_lty" target="_blank" rel="noopener noreferrer" class="nav-link external"><i class="iconfont reco-mayun"></i>
  Gitee
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li></ul></div></div> <!----></nav> <!----> </aside> <div class="password-shadow password-wrapper-in" style="display:none;" data-v-25ba6db2 data-v-1aefc0b4><h3 class="title" data-v-25ba6db2 data-v-25ba6db2>知识总结（六）JavaScript基础</h3> <!----> <label id="box" class="inputBox" data-v-25ba6db2 data-v-25ba6db2><input type="password" value="" data-v-25ba6db2> <span data-v-25ba6db2>Konck! Knock!</span> <button data-v-25ba6db2>OK</button></label> <div class="footer" data-v-25ba6db2 data-v-25ba6db2><span data-v-25ba6db2><i class="iconfont reco-theme" data-v-25ba6db2></i> <a target="blank" href="https://vuepress-theme-reco.recoluan.com" data-v-25ba6db2>vuePress-theme-reco</a></span> <span data-v-25ba6db2><i class="iconfont reco-copyright" data-v-25ba6db2></i> <a data-v-25ba6db2><span data-v-25ba6db2>lty</span>
            
          <!---->
          2022
        </a></span></div></div> <div data-v-1aefc0b4><main class="page"><section><div class="page-title"><h1 class="title">知识总结（六）JavaScript基础</h1> <div data-v-f875f3fc><i class="iconfont reco-account" data-v-f875f3fc><span data-v-f875f3fc>lty</span></i> <i class="iconfont reco-date" data-v-f875f3fc><span data-v-f875f3fc>2/11/2022</span></i> <i class="iconfont reco-eye" data-v-f875f3fc><span id="/blog/blogs/Summary/6.js.html" data-flag-title="Your Article Title" class="leancloud-visitors" data-v-f875f3fc><a class="leancloud-visitors-count" style="font-size:.9rem;font-weight:normal;color:#999;"></a></span></i> <i class="tags iconfont reco-tag" data-v-f875f3fc><span class="tag-item" data-v-f875f3fc>JavaScript</span></i></div></div> <div class="theme-reco-content content__default"><h2 id="基本数据类型"><a href="#基本数据类型" class="header-anchor">#</a> 基本数据类型</h2> <p>在 JS 中共有 <code>8</code> 种数据类型，分别为：Number、String、Boolean、undefined、object、Null、Symbol、 bigInt</p> <p>其中 <code>Symbol</code> 和 <code>BigInt</code> 是 ES6 新增的数据类型，可能会被单独问：</p> <ul><li>Symbol 代表独一无二的值，最大的用法是用来定义对象的唯一属性名。</li> <li>BigInt 可以表示任意大小的整数。</li></ul> <p><strong>基本类型、引用类型</strong></p> <ul><li><p>基本类型（值类型）：除Object。 String、Number、boolean、null、undefined，存储在栈里。</p></li> <li><p>引用类型：object。里面包含的 function、Array、Date，储存在栈和堆里，。</p></li> <li><p>引用类型存储：</p> <p><img src="https://gitee.com/ekzodia_lty/blog-image/raw/master/img/20220318140915.png" alt=""></p></li></ul> <h2 id="判断数据类型的方法"><a href="#判断数据类型的方法" class="header-anchor">#</a> 判断数据类型的方法</h2> <p><strong>typeof</strong>：能判断所有<strong>值类型，函数</strong>。不可对 <strong>null、对象、数组</strong>进行精确判断，因为都返回 <code>object</code></p> <div class="language-js line-numbers-mode"><pre class="language-js"><code>console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token keyword">typeof</span> <span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">;</span><span class="token comment">//number</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token keyword">typeof</span> <span class="token string">'1'</span><span class="token punctuation">)</span><span class="token punctuation">;</span><span class="token comment">//string</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><blockquote><p>typeof null === &quot;object&quot;; 的问题</p> <p>《你不知道的JavaScript》——
正确的返回结果应该是 “null”，但这个 bug 由来已久，在 JavaScript 中已经存在了将近 二十年，也许永远也不会修复，因为这牵涉到太多的 Web 系统，“修复”它会产生更多的 bug，令许多系统无法正常工作。</p></blockquote> <p><strong>instanceof</strong>：能判断<strong>对象</strong>类型，不能判断基本数据类型，<strong>其内部运行机制是判断在其原型链中能否找到该类型的原型</strong>。其实现就是顺着<strong>原型链</strong>去找，如果能找到对应的 <code>Xxxxx.prototype</code> 即为 <code>true</code></p> <div class="language-js line-numbers-mode"><pre class="language-js"><code>console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token punctuation">]</span> <span class="token keyword">instanceof</span> <span class="token class-name">Array</span><span class="token punctuation">)</span><span class="token punctuation">;</span><span class="token comment">//true</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token punctuation">]</span> <span class="token keyword">instanceof</span> <span class="token class-name">Object</span><span class="token punctuation">)</span><span class="token punctuation">;</span><span class="token comment">//true</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p>constructor</p> <div class="language-js line-numbers-mode"><pre class="language-js"><code>console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">Number</span><span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">.</span>constructor <span class="token operator">==</span> Number<span class="token punctuation">)</span><span class="token punctuation">;</span><span class="token comment">//true</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">String</span><span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">.</span>constructor <span class="token operator">==</span> String<span class="token punctuation">)</span><span class="token punctuation">;</span><span class="token comment">//true</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p><strong>Object.prototype.toString.call()</strong>：所有原始数据类型都是能判断的，还有 <strong>Error 对象，Date 对象</strong>等。</p> <div class="language-js line-numbers-mode"><pre class="language-js"><code><span class="token class-name">Object</span><span class="token punctuation">.</span>prototype<span class="token punctuation">.</span><span class="token function">toString</span><span class="token punctuation">.</span><span class="token function">call</span><span class="token punctuation">(</span><span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// &quot;[object Number]&quot;</span>
<span class="token class-name">Object</span><span class="token punctuation">.</span>prototype<span class="token punctuation">.</span><span class="token function">toString</span><span class="token punctuation">.</span><span class="token function">call</span><span class="token punctuation">(</span><span class="token string">&quot;&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// &quot;[object String]&quot;</span>
<span class="token class-name">Object</span><span class="token punctuation">.</span>prototype<span class="token punctuation">.</span><span class="token function">toString</span><span class="token punctuation">.</span><span class="token function">call</span><span class="token punctuation">(</span><span class="token boolean">true</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// &quot;[object Boolean]&quot;</span>
<span class="token class-name">Object</span><span class="token punctuation">.</span>prototype<span class="token punctuation">.</span><span class="token function">toString</span><span class="token punctuation">.</span><span class="token function">call</span><span class="token punctuation">(</span><span class="token keyword">undefined</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// &quot;[object Undefined]&quot;</span>
<span class="token class-name">Object</span><span class="token punctuation">.</span>prototype<span class="token punctuation">.</span><span class="token function">toString</span><span class="token punctuation">.</span><span class="token function">call</span><span class="token punctuation">(</span><span class="token keyword">null</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// &quot;[object Null]&quot;</span>
<span class="token class-name">Object</span><span class="token punctuation">.</span>prototype<span class="token punctuation">.</span><span class="token function">toString</span><span class="token punctuation">.</span><span class="token function">call</span><span class="token punctuation">(</span>Math<span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// &quot;[object Math]&quot;</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br></div></div><h2 id="严格模式"><a href="#严格模式" class="header-anchor">#</a> 严格模式</h2> <p>'use strict'</p> <ul><li>全局变量必须声明  n=1;//error</li> <li>禁用with</li> <li>创建eval作用域</li> <li>禁止this指向window</li> <li>函数参数名不能重复</li></ul> <h2 id="null-和-undefined-有什么区别"><a href="#null-和-undefined-有什么区别" class="header-anchor">#</a> null 和 undefined 有什么区别？</h2> <p>undefined 是没有定义的，null 是定义了但是为空。</p> <h2 id="和-的区别"><a href="#和-的区别" class="header-anchor">#</a> ==和===的区别</h2> <p>&quot;===&quot;叫做严格运算符，&quot;==&quot;叫做相等运算符。</p> <p>&quot;==&quot;会造成 类型转换,如果两个参数中一个为null，另一个为undefined，那么返回true</p> <p>&quot;===&quot;只要类型不一致，它就直接返回false,如果两个参数中一个为null，另一个为undefined，那么返回false</p> <h2 id="es6新特性"><a href="#es6新特性" class="header-anchor">#</a> ES6新特性</h2> <p>let和const命令，字符串模板，结构表达式，箭头函数，对象里的函数属性简写，数组的map和reduce方法，扩展运算符，promise，set和map，Generator函数，for…of循环。</p> <h2 id="var-let-const的区别"><a href="#var-let-const的区别" class="header-anchor">#</a> var,let,const的区别</h2> <p>let和var的区别：</p> <ul><li>let声明的范围是块作用域，而var声明的范围是函数作用域；</li> <li>let声明的变量不会在作用域中被提升，会出现暂时性死区；</li> <li>let不允许同一个块级作用域中出现冗余声明；</li> <li>var在全局作用域中声明的变量会成为windows对象的属性，而let不会。</li></ul> <p>const和let的区别：</p> <ul><li>cosnt声明变量的同时必须初始化变量，且修改const声明的变量会导致运行错误；</li> <li>如果cosnt变量引用的是一个对象，那么可以修改这个对象的内部属性；</li></ul> <h2 id="暂时性死区"><a href="#暂时性死区" class="header-anchor">#</a> 暂时性死区</h2> <p>在解析代码时，JavaScript引擎也会注意出现在块后面的let声明，只不过在此之前不能以任何方式来引用未声明的变量。在let声明之前的执行瞬间被称为“暂时性死区”，在此阶段引用任何后面才声明的变量都会抛出ReferenceError。</p> <h2 id="for-in-和for-of的区别"><a href="#for-in-和for-of的区别" class="header-anchor">#</a> for in 和for of的区别</h2> <ul><li><p>for in 遍历的是数组的索引（index），for of 遍历的是数组的元素值（value）。</p></li> <li><p>for in更适合遍历对象，遍历数组会存在一些问题（index为索引的字符串型数字，不能直接进行几何运算）</p></li> <li><p>for of很适合遍历数组,<strong>不能遍历对象</strong>，es6新语法，可以使用 break 和 continue 跳出循环，通过arr.keys()的方法可以打印数组的索引。</p></li> <li><p>for...in用于<strong>可枚举</strong>数据，比如对象、数组、字符串；</p> <p>for...of用于<strong>可迭代</strong>数据，比如数组、字符串、Map、Set；</p></li></ul> <p>enumerable可枚举</p> <p><strong>for in</strong></p> <div class="language-js line-numbers-mode"><pre class="language-js"><code><span class="token comment">//for in</span>
<span class="token comment">//for of很适合遍历数组,不能遍历对象,error:obj is not iterable</span>
<span class="token keyword">var</span> obj <span class="token operator">=</span> <span class="token punctuation">{</span>a<span class="token operator">:</span><span class="token number">1</span><span class="token punctuation">,</span>b<span class="token operator">:</span><span class="token number">2</span><span class="token punctuation">,</span>c<span class="token operator">:</span><span class="token number">3</span><span class="token punctuation">}</span><span class="token punctuation">;</span>

<span class="token keyword">for</span><span class="token punctuation">(</span><span class="token keyword">let</span> key <span class="token keyword">in</span> obj<span class="token punctuation">)</span><span class="token punctuation">{</span>
	console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>key<span class="token punctuation">)</span><span class="token punctuation">;</span><span class="token comment">//a,b,c</span>
    console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>obj<span class="token punctuation">[</span>key<span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span><span class="token comment">//0,1,2</span>
<span class="token punctuation">}</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br></div></div><p><strong>for of</strong></p> <div class="language-js line-numbers-mode"><pre class="language-js"><code><span class="token comment">//for of</span>
<span class="token comment">//for in更适合遍历对象，遍历数组会存在一些问题（index为索引的字符串型数字，不能直接进行几何运算）</span>
<span class="token keyword">const</span> arr <span class="token operator">=</span> <span class="token punctuation">[</span><span class="token string">'a'</span><span class="token punctuation">,</span><span class="token string">'b'</span><span class="token punctuation">,</span><span class="token string">'c'</span><span class="token punctuation">]</span><span class="token punctuation">;</span>

<span class="token keyword">for</span><span class="token punctuation">(</span><span class="token keyword">const</span> val <span class="token keyword">of</span> arr<span class="token punctuation">)</span><span class="token punctuation">{</span>
    console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>val<span class="token punctuation">)</span><span class="token punctuation">;</span><span class="token comment">//a,b,c</span>
<span class="token punctuation">}</span>
<span class="token comment">//利用keys方法打印数组的索引 </span>
<span class="token keyword">for</span><span class="token punctuation">(</span><span class="token keyword">let</span> key <span class="token keyword">of</span> arr<span class="token punctuation">.</span><span class="token function">keys</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
    console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>key<span class="token punctuation">)</span><span class="token punctuation">;</span><span class="token comment">//0,1,2</span>
<span class="token punctuation">}</span>
<span class="token comment">//for of遍历Map</span>
<span class="token keyword">const</span> myMap <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">Map</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
  <span class="token punctuation">.</span><span class="token function">set</span><span class="token punctuation">(</span><span class="token boolean">false</span><span class="token punctuation">,</span> <span class="token string">'no'</span><span class="token punctuation">)</span>
  <span class="token punctuation">.</span><span class="token function">set</span><span class="token punctuation">(</span><span class="token boolean">true</span><span class="token punctuation">,</span> <span class="token string">'yes'</span><span class="token punctuation">)</span>
<span class="token punctuation">;</span>
<span class="token keyword">for</span> <span class="token punctuation">(</span><span class="token keyword">const</span> <span class="token punctuation">[</span>key<span class="token punctuation">,</span> value<span class="token punctuation">]</span> <span class="token keyword">of</span> myMap<span class="token punctuation">)</span> <span class="token punctuation">{</span>
  console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>key<span class="token punctuation">,</span> value<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
<span class="token comment">// Output:</span>
<span class="token comment">// false, 'no'</span>
<span class="token comment">// true, 'yes'</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br></div></div><p><strong>forEach</strong></p> <div class="language-js line-numbers-mode"><pre class="language-js"><code><span class="token comment">//数组的迭代方法forEach</span>
<span class="token comment">//forEach速度比for慢，因为forEach每次都要创建一个函数调用;</span>
<span class="token keyword">const</span> array1 <span class="token operator">=</span> <span class="token punctuation">[</span><span class="token string">'a'</span><span class="token punctuation">,</span> <span class="token string">'b'</span><span class="token punctuation">,</span> <span class="token string">'c'</span><span class="token punctuation">]</span><span class="token punctuation">;</span>
array1<span class="token punctuation">.</span><span class="token function">forEach</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token parameter">item<span class="token punctuation">,</span> index<span class="token punctuation">,</span> array</span><span class="token punctuation">)</span> <span class="token operator">=&gt;</span> console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>item<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span><span class="token comment">//a,b,c</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br></div></div><h2 id="for-await-of有什么作用"><a href="#for-await-of有什么作用" class="header-anchor">#</a> for await...of有什么作用</h2> <p>用于遍历多个Promise ，类似promise.all。</p> <div class="language-js line-numbers-mode"><pre class="language-js"><code><span class="token keyword">const</span> p1<span class="token operator">=</span><span class="token function">createPromisr</span><span class="token punctuation">(</span><span class="token number">100</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">const</span> p2<span class="token operator">=</span><span class="token function">createPromisr</span><span class="token punctuation">(</span><span class="token number">200</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">const</span> p3<span class="token operator">=</span><span class="token function">createPromisr</span><span class="token punctuation">(</span><span class="token number">300</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">const</span> list <span class="token operator">=</span> <span class="token punctuation">[</span>p1<span class="token punctuation">,</span>p2<span class="token punctuation">,</span>p3<span class="token punctuation">]</span><span class="token punctuation">;</span>
Promise<span class="token punctuation">.</span><span class="token function">all</span><span class="token punctuation">(</span>list<span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">then</span><span class="token punctuation">(</span><span class="token parameter">res</span><span class="token operator">=&gt;</span>console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>res<span class="token punctuation">)</span><span class="token punctuation">)</span>
<span class="token keyword">for</span> <span class="token keyword">await</span> <span class="token punctuation">(</span><span class="token keyword">let</span> res <span class="token keyword">of</span> list<span class="token punctuation">)</span><span class="token punctuation">{</span>
	console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>res<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br></div></div><h2 id="字符串的常用方法"><a href="#字符串的常用方法" class="header-anchor">#</a> 字符串的常用方法</h2> <ul><li>length返回字符串长度；</li> <li>indexOf() 方法返回字符串中指定文本<em>首次</em>出现的索引位置（没找到返回-1）；</li> <li>lastIndexOf() 方法返回指定文本在字符串中<em>最后</em>一次出现的索引；</li> <li>replace() 方法用另一个值替换在字符串中指定的值；</li> <li>concat() 连接两个或多个字符串；</li> <li>trim() 方法删除字符串两端的空白符；</li> <li>charAt() 方法返回字符串中指定下标（位置）的字符串；</li> <li>可以通过 split() 将字符串转换为数组；</li> <li>提取部分字符串的方法：
<ul><li>slice(<em>start</em>, <em>end</em>)</li> <li>substring(<em>start</em>, <em>end</em>)（与slice类似，不过无法接受负索引）</li> <li>substr(<em>start</em>, <em>length</em>)</li></ul></li> <li>转换大小写
<ul><li>toLowerCase() 把字符串转换为小写；</li> <li>toUpperCase() 把字符串转换为大写；</li></ul></li></ul> <h2 id="number的常用方法"><a href="#number的常用方法" class="header-anchor">#</a> Number的常用方法</h2> <ul><li>isFinite检测数组是否无穷大；</li> <li>toFixed(x)把数字转化为字符串，结果的小数点后有指定位数的数字；</li> <li>toString()把数组转换为字符串，括号里可以写几进制；</li> <li>toPrecision(x)把数字格式化为指定的长度（四舍五入）；</li></ul> <h2 id="数组的常用方法"><a href="#数组的常用方法" class="header-anchor">#</a> 数组的常用方法</h2> <p><strong>增加删除方法</strong></p> <ul><li>Array.push()，向数组的末尾添加一个或多个元素，并返回新的数组长度。原数组改变。</li> <li>Array.pop()，删除并返回数组的最后一个元素，若该数组为空，则返回undefined。原数组改变</li> <li>Array.unshift()，向数组的开头添加一个或多个元素，并返回新的数组长度。原数组改变。</li> <li>Array.shift()，删除数组的第一项，并返回第一个元素的值。若该数组为空，则返回undefined。原数组改变。</li></ul> <p><strong>迭代归并方法</strong></p> <ul><li><p>Array.map(function)，原数组的每一项执行函数后，返回一个新的数组。原数组不变。（注意该方法和forEach的区别）。</p></li> <li><p>Array.forEach(function)，用于调用数组的每个元素，并将元素传递给回调函数。原数组不变。（注意该方法和map的区别，若直接打印Array.forEach，结果为undefined）。</p></li> <li><p>Array.filter(function)，过滤数组中，符合条件的元素并返回一个新的数组。</p></li> <li><p>Array.every(function)，对数组中的每一项进行判断，若都符合则返回true，否则返回false。</p></li> <li><p>Array.some(function)，对数组中的每一项进行判断，若都不符合则返回false，否则返回true。</p></li> <li><p>Array.reduce(function)，reduce() 方法接收一个函数作为累加器，数组中的每个值（从左到右）开始缩减，最终计算为一个值。</p></li></ul> <p><strong>其他方法</strong></p> <ol><li>Array.concat(arr1,arr2...)，合并两个或多个数组，生成一个新的数组。原数组不变。</li> <li>Array.join()，将数组的每一项用指定字符连接形成一个字符串。默认连接字符为 “,” 逗号。</li> <li>Array.reverse()，将数组倒序。原数组改变。</li> <li>Array.sort()，对数组元素进行排序。按照字符串UniCode码排序，原数组改变。</li> <li>Array.toString()，将数组转化为字符串，并返回结果；</li> <li>Array.slice(start,end)，从start开始，end之前结束，不到end；如果不给end值，从start开始到数组结束；</li> <li>Array.splice(index,howmany,arr1,arr2...) ，删除元素并添加元素，从index位置开始删除howmany个元素，并将arr1、arr2...数据从index位置依次插入。howmany为0时，则不删除元素。原数组改变。</li> <li>Array.indexOf() 在数组中搜索元素并返回其位置。</li> <li>Array.includes()检查数组是否包含指定的元素。</li> <li>Array.isArray()检查对象是否为数组。</li> <li>Array.fill用静态值填充数组中的元素。</li></ol> <h2 id="对象的常用方法"><a href="#对象的常用方法" class="header-anchor">#</a> 对象的常用方法</h2> <ul><li><p>Object.is(value1, value2)是一种判断两个值是否相同的方法。</p></li> <li><p>Object.entries() 方法返回给定对象自己的可枚举字符串键属性 [key, value] 对的数组。</p></li> <li><p>Object.assign()用于将所有可枚举的自身属性从一个或多个源对象复制到目标对象。</p></li> <li><p>Object.prototype.hasOwnProperty()hasOwnProperty() 方法返回一个布尔值，指示对象是否具有指定的属性作为它自己的属性。</p></li> <li><p>Object.freeze()方法冻结一个对象，这意味着它不能再被更改。</p></li></ul> <p>isPrototypeOf</p> <p>propertyIsEnumerable</p> <p>toString</p> <h2 id="this指向问题"><a href="#this指向问题" class="header-anchor">#</a> this指向问题</h2> <p>在标准函数中，this引用的是把函数当成方法调用的上下文对象，这时候通常称其为this值（在网页的全局上下文中调用函数时，this指向windows）。</p> <p>普通函数下的this:</p> <ul><li><strong>在普通函数中的this始终指向的是调用它的对象</strong>，在默认情况下，this指的是window；</li> <li>在严格模式下,没有直接调用者的函数中的this是 undefined使用；</li> <li>call,apply,bind(ES5新增)绑定的,this指的是 绑定的对象。</li></ul> <p><strong>在箭头函数中，指向它的父级作用域</strong>，而不是调用它对象，this的指向绑定的时机是有区别的，箭头函数在定义时已经绑定，普通函数只会在调用时确定。</p> <p><strong>this绑定的优先级</strong></p> <ol><li><p>new绑定是指函数的构造调用；</p></li> <li><p>显示绑定是call，apply，bind；</p></li> <li><p>隐式绑定是对象调用方法，obj.foo();这种；</p></li> <li><p>默认绑定：直接使用而不带任何修饰的函数调用，一般指向window，严格模式是undefined。</p></li></ol> <p><strong>new 绑定 &gt; 显示绑定 &gt; 隐式绑定 &gt; 默认绑定</strong></p> <hr> <h2 id="call-apply-bind"><a href="#call-apply-bind" class="header-anchor">#</a> call apply bind</h2> <p>call 、bind 、 apply 这三个函数的第一个参数都是 this 的指向对象，不传参数指向全局window对象，第二个参数差别就来了：</p> <blockquote><p>call 的参数是直接放进去的，第二第三第 n 个参数全都用逗号分隔，直接放到后面 ,obj.myFun.call(db,'成都', ... ,'string' )。</p></blockquote> <blockquote><p>apply 的所有参数都必须放在一个数组里面传进去 ,obj.myFun.apply(db,['成都', ..., 'string' ])。</p></blockquote> <blockquote><p>bind返回的是一个新的函数，必须要调用它才会被执行。 除了返回是函数以外，它的参数和 call 一样，用逗号分隔开来。</p></blockquote> <p>当然，三者的参数不限定是 string 类型，允许是各种类型，包括函数 、 object 等等！</p> <h2 id="闭包"><a href="#闭包" class="header-anchor">#</a> 闭包</h2> <p>所有的自由变量的查找，是在函数定义的地方，向上级作用域查找，不是在执行的地方。</p> <p><strong>本质就是上级作用域内变量的生命周期，因为被下级作用域内引用，而没有被释放。就导致上级作用域内的变量，等到下级作用域执行完以后才正常得到释放。</strong></p> <p><strong>实际应用</strong></p> <ul><li>闭包隐藏数据，只提供API；</li> <li>柯里化；</li></ul> <h2 id="用new-做到函数的构造调用后-js做了什么工作"><a href="#用new-做到函数的构造调用后-js做了什么工作" class="header-anchor">#</a> 用new 做到函数的构造调用后，js做了什么工作</h2> <ol><li>创建一个新对象。</li> <li>把这个新对象的__proto__属性指向 原函数的prototype属性。(即继承原函数的原型)</li> <li>将这个新对象绑定到 此函数的this上 。</li> <li>返回新对象，如果这个函数没有返回其他对象。</li></ol> <h2 id="箭头函数的优点"><a href="#箭头函数的优点" class="header-anchor">#</a> 箭头函数的优点</h2> <p>语法更加简洁，解决了this的指向问题，原生的写法this指向的是调用者，箭头函数this绑定的是定义时的那个对象。</p> <h2 id="箭头函数的缺点"><a href="#箭头函数的缺点" class="header-anchor">#</a> 箭头函数的缺点</h2> <ol><li>没有arguments；</li> <li>无法通过apply，call，bind改变this；</li> <li>不适用的场景：对象方法、对象原型、构造函数、Vue生命周期、Vue的method、动态上下文的回调函数；</li> <li>某些箭头函数代码难以阅读；</li></ol> <h2 id="宏任务和微任务"><a href="#宏任务和微任务" class="header-anchor">#</a> 宏任务和微任务</h2> <p>宏任务：如setTimeout、setInterva、l网络请求；</p> <p>微任务：如promise、async/await</p> <p><strong>微任务在下一轮DOM渲染之前执行，宏任务在之后执行。</strong></p> <h2 id="promise-all和promise-race的区别的使用场景"><a href="#promise-all和promise-race的区别的使用场景" class="header-anchor">#</a> Promise.all和Promise.race的区别的使用场景</h2> <p>（1）Promise.all Promise.all可以将多个Promise实例包装成一个新的Promise实例。同时，成功和失败的返回值是不同的，成功的时候返回的是一个结果数组，而失败的时候则返回最先被reject失败状态的值。</p> <p>Promise.all中传入的是数组，返回的也是是数组，并且会将进行映射，传入的promise对象返回的值是按照顺序在数组中排列的，但是注意的是他们执行的顺序并不是按照顺序的，除非可迭代对象为空。</p> <p>需要注意，Promise.all获得的成功结果的数组里面的数据顺序和Promise.all接收到的数组顺序是一致的，这样当遇到发送多个请求并根据请求顺序获取和使用数据的场景，就可以使用Promise.all来解决。</p> <p>（2）Promise.race</p> <p>顾名思义，Promse.race就是赛跑的意思，意思就是说，Promise.race([p1, p2, p3])里面哪个结果获得的快，就返回那个结果，不管结果本身是成功状态还是失败状态。当要做一件事，超过多长时间就不做了，可以用这个方法来解决：Promise.race([promise1,timeOutPromise(5000)]).then(res=&gt;{});</p> <hr> <h2 id="async-await"><a href="#async-await" class="header-anchor">#</a> async/await</h2> <ul><li>await只能在async函数中使用，不然会报错</li> <li>async函数返回的是一个状态为fuifilled的Promise对象，有无值看有无return值</li> <li>await后面只有接了Promise才能实现排队效果</li> <li>async/await作用是用同步方式，执行异步操作</li></ul> <hr> <h2 id="原型和原型链"><a href="#原型和原型链" class="header-anchor">#</a> 原型和原型链</h2> <p>对应名称</p> <p>prototype：原型</p> <p><strong>proto</strong>:原型链</p> <p>从属关系</p> <p>对象的__proto__保存着该对象的构造函数的prototype，Object---&gt;构造函数---&gt;普通函数，普通函数的原型链与其构造函数的原型完全相等。最下面的普通函数没有原型，只有原型链，Object原型上的原型链已经到顶部，为null。</p> <h2 id="内存泄漏的场景-vue为例"><a href="#内存泄漏的场景-vue为例" class="header-anchor">#</a> 内存泄漏的场景（Vue为例）</h2> <ul><li>被全局变量、函数引用，组件销毁时未清除；</li> <li>被全局事件、定时器引用，组件销毁是未清除；</li> <li>被自定义事件引用，销毁组件时未清除；</li></ul> <h2 id="weakmap和weakset"><a href="#weakmap和weakset" class="header-anchor">#</a> WeakMap和WeakSet</h2> <p>WeakMap的Key只能是引用类型。</p> <h2 id="什么是json"><a href="#什么是json" class="header-anchor">#</a> 什么是JSON</h2> <ul><li>JSON 是一种轻量级的数据交换格式。</li> <li>JSON 格式化后为 JavaScript 对象。</li></ul> <p>JSON.parse()用于将一个 JSON 字符串转换为 JavaScript 对象。</p> <p>JSON.stringify()用于将 JavaScript 值转换为 JSON 字符串。</p> <h2 id="script-标签中-defer-和-async-的区别"><a href="#script-标签中-defer-和-async-的区别" class="header-anchor">#</a> script 标签中 defer 和 async 的区别？</h2> <ul><li><code>script</code> ：会阻碍 HTML 解析，只有下载好并执行完脚本才会继续解析 HTML。</li> <li><code>async script</code> ：解析 HTML 过程中进行脚本的异步下载，下载成功立马执行，有可能会阻断 HTML 的解析。</li> <li><code>defer script</code>：完全不会阻碍 HTML 的解析，解析完成之后再按照顺序执行脚本。</li></ul> <p>您好，我叫李天遥，是22届的应届毕业生，学的专业是金融工程，接触前端有一年多了，有一直在自学，之前在厦门的稿定设计实习，主要负责杭州花瓣网的设计赛事的业务和设计工坊的开发，主要的技术栈是vue，实习四个月，现在是想去杭州发展。</p></div></section> <footer class="page-edit"><!----> <div class="last-updated"><span class="prefix">Last Updated: </span> <span class="time">4/17/2022, 11:14:29 PM</span></div></footer> <!----> <div class="comments-wrapper"><!----></div> <ul class="side-bar sub-sidebar-wrapper" style="width:12rem;" data-v-cb1513f6><li class="level-2" data-v-cb1513f6><a href="/blog/blogs/Summary/6.js.html#基本数据类型" class="sidebar-link reco-side-基本数据类型" data-v-cb1513f6>基本数据类型</a></li><li class="level-2" data-v-cb1513f6><a href="/blog/blogs/Summary/6.js.html#判断数据类型的方法" class="sidebar-link reco-side-判断数据类型的方法" data-v-cb1513f6>判断数据类型的方法</a></li><li class="level-2" data-v-cb1513f6><a href="/blog/blogs/Summary/6.js.html#严格模式" class="sidebar-link reco-side-严格模式" data-v-cb1513f6>严格模式</a></li><li class="level-2" data-v-cb1513f6><a href="/blog/blogs/Summary/6.js.html#null-和-undefined-有什么区别" class="sidebar-link reco-side-null-和-undefined-有什么区别" data-v-cb1513f6>null 和 undefined 有什么区别？</a></li><li class="level-2" data-v-cb1513f6><a href="/blog/blogs/Summary/6.js.html#和-的区别" class="sidebar-link reco-side-和-的区别" data-v-cb1513f6>==和===的区别</a></li><li class="level-2" data-v-cb1513f6><a href="/blog/blogs/Summary/6.js.html#es6新特性" class="sidebar-link reco-side-es6新特性" data-v-cb1513f6>ES6新特性</a></li><li class="level-2" data-v-cb1513f6><a href="/blog/blogs/Summary/6.js.html#var-let-const的区别" class="sidebar-link reco-side-var-let-const的区别" data-v-cb1513f6>var,let,const的区别</a></li><li class="level-2" data-v-cb1513f6><a href="/blog/blogs/Summary/6.js.html#暂时性死区" class="sidebar-link reco-side-暂时性死区" data-v-cb1513f6>暂时性死区</a></li><li class="level-2" data-v-cb1513f6><a href="/blog/blogs/Summary/6.js.html#for-in-和for-of的区别" class="sidebar-link reco-side-for-in-和for-of的区别" data-v-cb1513f6>for in 和for of的区别</a></li><li class="level-2" data-v-cb1513f6><a href="/blog/blogs/Summary/6.js.html#for-await-of有什么作用" class="sidebar-link reco-side-for-await-of有什么作用" data-v-cb1513f6>for await...of有什么作用</a></li><li class="level-2" data-v-cb1513f6><a href="/blog/blogs/Summary/6.js.html#字符串的常用方法" class="sidebar-link reco-side-字符串的常用方法" data-v-cb1513f6>字符串的常用方法</a></li><li class="level-2" data-v-cb1513f6><a href="/blog/blogs/Summary/6.js.html#number的常用方法" class="sidebar-link reco-side-number的常用方法" data-v-cb1513f6>Number的常用方法</a></li><li class="level-2" data-v-cb1513f6><a href="/blog/blogs/Summary/6.js.html#数组的常用方法" class="sidebar-link reco-side-数组的常用方法" data-v-cb1513f6>数组的常用方法</a></li><li class="level-2" data-v-cb1513f6><a href="/blog/blogs/Summary/6.js.html#对象的常用方法" class="sidebar-link reco-side-对象的常用方法" data-v-cb1513f6>对象的常用方法</a></li><li class="level-2" data-v-cb1513f6><a href="/blog/blogs/Summary/6.js.html#this指向问题" class="sidebar-link reco-side-this指向问题" data-v-cb1513f6>this指向问题</a></li><li class="level-2" data-v-cb1513f6><a href="/blog/blogs/Summary/6.js.html#call-apply-bind" class="sidebar-link reco-side-call-apply-bind" data-v-cb1513f6>call apply bind</a></li><li class="level-2" data-v-cb1513f6><a href="/blog/blogs/Summary/6.js.html#闭包" class="sidebar-link reco-side-闭包" data-v-cb1513f6>闭包</a></li><li class="level-2" data-v-cb1513f6><a href="/blog/blogs/Summary/6.js.html#用new-做到函数的构造调用后-js做了什么工作" class="sidebar-link reco-side-用new-做到函数的构造调用后-js做了什么工作" data-v-cb1513f6>用new 做到函数的构造调用后，js做了什么工作</a></li><li class="level-2" data-v-cb1513f6><a href="/blog/blogs/Summary/6.js.html#箭头函数的优点" class="sidebar-link reco-side-箭头函数的优点" data-v-cb1513f6>箭头函数的优点</a></li><li class="level-2" data-v-cb1513f6><a href="/blog/blogs/Summary/6.js.html#箭头函数的缺点" class="sidebar-link reco-side-箭头函数的缺点" data-v-cb1513f6>箭头函数的缺点</a></li><li class="level-2" data-v-cb1513f6><a href="/blog/blogs/Summary/6.js.html#宏任务和微任务" class="sidebar-link reco-side-宏任务和微任务" data-v-cb1513f6>宏任务和微任务</a></li><li class="level-2" data-v-cb1513f6><a href="/blog/blogs/Summary/6.js.html#promise-all和promise-race的区别的使用场景" class="sidebar-link reco-side-promise-all和promise-race的区别的使用场景" data-v-cb1513f6>Promise.all和Promise.race的区别的使用场景</a></li><li class="level-2" data-v-cb1513f6><a href="/blog/blogs/Summary/6.js.html#async-await" class="sidebar-link reco-side-async-await" data-v-cb1513f6>async/await</a></li><li class="level-2" data-v-cb1513f6><a href="/blog/blogs/Summary/6.js.html#原型和原型链" class="sidebar-link reco-side-原型和原型链" data-v-cb1513f6>原型和原型链</a></li><li class="level-2" data-v-cb1513f6><a href="/blog/blogs/Summary/6.js.html#内存泄漏的场景-vue为例" class="sidebar-link reco-side-内存泄漏的场景-vue为例" data-v-cb1513f6>内存泄漏的场景（Vue为例）</a></li><li class="level-2" data-v-cb1513f6><a href="/blog/blogs/Summary/6.js.html#weakmap和weakset" class="sidebar-link reco-side-weakmap和weakset" data-v-cb1513f6>WeakMap和WeakSet</a></li><li class="level-2" data-v-cb1513f6><a href="/blog/blogs/Summary/6.js.html#什么是json" class="sidebar-link reco-side-什么是json" data-v-cb1513f6>什么是JSON</a></li><li class="level-2" data-v-cb1513f6><a href="/blog/blogs/Summary/6.js.html#script-标签中-defer-和-async-的区别" class="sidebar-link reco-side-script-标签中-defer-和-async-的区别" data-v-cb1513f6>script 标签中 defer 和 async 的区别？</a></li></ul></main> <!----></div></div></div></div><div class="global-ui"><div class="back-to-ceiling" style="right:1rem;bottom:6rem;width:2.5rem;height:2.5rem;border-radius:.25rem;line-height:2.5rem;display:none;" data-v-c6073ba8 data-v-c6073ba8><svg t="1574745035067" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5404" class="icon" data-v-c6073ba8><path d="M526.60727968 10.90185116a27.675 27.675 0 0 0-29.21455937 0c-131.36607665 82.28402758-218.69155461 228.01873535-218.69155402 394.07834331a462.20625001 462.20625001 0 0 0 5.36959153 69.94390903c1.00431239 6.55289093-0.34802892 13.13561351-3.76865779 18.80351572-32.63518765 54.11355614-51.75690182 118.55860487-51.7569018 187.94566865a371.06718723 371.06718723 0 0 0 11.50484808 91.98906777c6.53300375 25.50556257 41.68394495 28.14064038 52.69160883 4.22606766 17.37162448-37.73630017 42.14135425-72.50938081 72.80769204-103.21549295 2.18761121 3.04276886 4.15646224 6.24463696 6.40373557 9.22774369a1871.4375 1871.4375 0 0 0 140.04691725 5.34970492 1866.36093723 1866.36093723 0 0 0 140.04691723-5.34970492c2.24727335-2.98310674 4.21612437-6.18497483 6.3937923-9.2178004 30.66633723 30.70611158 55.4360664 65.4791928 72.80769147 103.21549355 11.00766384 23.91457269 46.15860503 21.27949489 52.69160879-4.22606768a371.15156223 371.15156223 0 0 0 11.514792-91.99901164c0-69.36717486-19.13165746-133.82216804-51.75690182-187.92578088-3.42062944-5.66790279-4.76302748-12.26056868-3.76865837-18.80351632a462.20625001 462.20625001 0 0 0 5.36959269-69.943909c-0.00994388-166.08943902-87.32547796-311.81420293-218.6915546-394.09823051zM605.93803103 357.87693858a93.93749974 93.93749974 0 1 1-187.89594924 6.1e-7 93.93749974 93.93749974 0 0 1 187.89594924-6.1e-7z" p-id="5405" data-v-c6073ba8></path><path d="M429.50777625 765.63860547C429.50777625 803.39355007 466.44236686 1000.39046097 512.00932183 1000.39046097c45.56695499 0 82.4922232-197.00623328 82.5015456-234.7518555 0-37.75494459-36.9345906-68.35043303-82.4922232-68.34111062-45.57627738-0.00932239-82.52019037 30.59548842-82.51086798 68.34111062z" p-id="5406" data-v-c6073ba8></path></svg></div></div></div>
    <script src="/blog/assets/js/app.2c497286.js" defer></script><script src="/blog/assets/js/3.1e41fb2d.js" defer></script><script src="/blog/assets/js/1.a1bf8e1e.js" defer></script><script src="/blog/assets/js/36.3350110b.js" defer></script>
  </body>
</html>
